// let years=['今日','明日']
// let months= ['8:00 - 10:00', '10:00 - 12:00', '12:00 - 14:00','14:00 - 16:00','16:00 - 18:00','18:00 - 20:00','20:00 - 22:00'];
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    dateIndex: Number,
    timeIndex: Number,
    placeholder: String,
    dates: Array,
    times:Array
  },

  /**
   * 组件的初始数据
   */
  data: {
    // years,
    // timeList:months,
    dateRange: '',
    timeRange: ''
  },
  observers:{
    dateIndex: function(v) {
      this.setData({
        dateRange: this.data.dates[v] 
      })
    },
    timeIndex: function(v) {
      this.setData({
        timeRange: this.data.times[v] 
      })
    },
  },
/**
   * 组件的方法列表
   */
  methods: {
    handleValueChange(e){
      let index = e.detail.value
      this.setData({
        dateIndex: index,
        dateRange: this.data.dates[index] 
      })
      this.triggerEvent('dateDate',{
        dateIndex: index,
        dateRange: this.data.dates[index] 
      })
    },
    handleCancel() {
      this.setData({
        dateRange: this.data.dates[0]
      })
      this.triggerEvent('dateDate',{
        dateIndex: 0,
        dateRange: this.data.dates[0] 
      })
    },
    handleTimeCancel() {
      this.setData({
        timeRange: this.data.times[0]
      })
      this.triggerEvent('timeDate',{
        dateIndex: 0,
        dateRange: this.data.times[0] 
      })
    },
    handleTimeChange(e){
      let index = e.detail.value
      this.setData({
        timeIndex: index,
        timeRange: this.data.times[index]
      })
      this.triggerEvent('timeDate',{
        timeIndex: index,
        timeRange: this.data.times[index]
      })
    },
  }
})